<html>
    <head>
        <style>
            body {
                padding: 0;
                margin: 0;
            }

            #parent {
                position: relative;
                width: 200px;
                height: 200px;
                background-color: #00cc88;
            }

            #mid {
                position: absolute;
                width: auto;
                height: auto;
                left: 0;
                top: 0;
            }

            .b #mid {
                left: 100px;
            }

            #child {
                width: 50px;
                height: 50px;
                background-color: #0077ff;
            }

            [data-layout-correct="false"] {
                background: #dd1144 !important;
                opacity: 0.5;
            }
        </style>
    </head>
    <body>
        <div id="parent">
            <div id="mid"><div id="child" /></div>
        </div>

        <script type="module" src="/src/imports/projection.js"></script>
        <script type="module" src="/src/imports/script-assert.js"></script>
        <script type="module" src="/src/imports/script-animate.js"></script>
        <script type="module">
            const { createNode, relativeEase } = window.Animate
            const { matchViewportBox } = window.Assert
            const { frame } = window.Projection

            const parent = document.getElementById("parent")
            const mid = document.getElementById("mid")
            const child = document.getElementById("child")

            const parentProjection = createNode(
                parent,
                undefined,
                {},
                { duration: 0 }
            )
            const midProjection = createNode(
                mid,
                parentProjection,
                {},
                { duration: 0 }
            )
            const childProjection = createNode(
                child,
                midProjection,
                {},
                { type: false }
            )

            parentProjection.willUpdate()
            midProjection.willUpdate()
            childProjection.willUpdate()

            parent.classList.add("b")

            parentProjection.root.didUpdate()

            frame.postRender(() => {
                frame.postRender(() => {
                    matchViewportBox(mid, {
                        bottom: 50,
                        left: 100,
                        right: 150,
                        top: 0,
                    })
                    matchViewportBox(child, {
                        bottom: 50,
                        left: 100,
                        right: 150,
                        top: 0,
                    })
                })
            })
        </script>
    </body>
</html>
